﻿using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using SPSolutions.Samples.PickerApp.WebControls;

namespace SPSolutions.Samples.PickerApp.Layouts.PickerApp
{
    /// <summary>
    /// Represent a picker page
    /// </summary>
    public partial class PickerPage : LayoutsPageBase
    {
        // Fields
        protected CityEditor CityEditorSingle;
        protected CityEditor CityEditorMultiple;

        /// <summary>
        /// Load the page
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        
        /// <summary>
        /// On city context change method
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void CitySelector_ContextChange(object sender, EventArgs e)
        {
            Response.Write("CitySelector_ContextChange");
        }

        /// <summary>
        /// Get selected cities
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void FinishButton_Click(object sender, EventArgs e)
        {
            foreach (PickerEntity entity in CityEditorMultiple.ResolvedEntities)
            {
                Response.Write(String.Format("City: {0}<br />", entity.Key));
            }
        }
    }
}
